<?php
define('ADMIN',1);
define('ADMINROOT',str_replace(DIRECTORY_SEPARATOR,'/',dirname(__FILE__)));
define('ADMINTPL',ADMINROOT.'/template');
include_once '../libs/ez.config.php';
define('ADMINDIR',str_replace(EZROOT,'',ADMINROOT));

$domain_url=get_domain();

$topnav_arr=array("system"=>"系统管理","workspace"=>"管理工作台","member"=>"会员中心","options"=>"互动功能组件","content"=>"内容工作台");
$topnav_arr["caipu"]="菜谱管理";
$topnav_arr["order"]="订单管理";
$topnav_arr["caigou"]="采购管理";
$topnav_arr["work"]="加工管理";
$topnav_arr["zhijian"]="质检管理";
$topnav_arr["wuliu"]="物流管理";
$topnav_arr["kefu"]="客服管理";
$topnav_arr["weixin"]="微信管理";
$topnav_arr["coupon"]="优惠劵管理";
$subactlist=array("system","workspace","member","options","content","caipu","order","caigou","work","zhijian","wuliu","kefu","weixin","coupon");

$workflowlist=array("0"=>"不需要审核","1"=>"一级审核",2=>"二级审核");
$state_arr=array("0"=>"草稿","1"=>"待审核","2"=>"待二审",3=>"待三审",14=>"作废",99=>"发布");

$stylelist=array("0"=>"列表","1"=>"图片");
        
$linktypelist=array("0"=>"LOGO链接","1"=>"文字链接");


$shoestatuslist=array("0"=>"未开启","1"=>"已开启");

$inteview_arr=array("1"=>"邀请面试","2"=>"确认面试","4"=>"取消面试",3=>"面试合格",5=>"面试不合格");
$zhobotypelist=array("1"=>"开庭直播","2"=>"活动直播");

$openstatuslist=array("0"=>"暂停","1"=>"开放","2"=>"闭版");
$adspacelist=array("banner"=>"横幅广告","code"=>"代码广告");
$allowstatuslist=array("0"=>"暂停","1"=>"允许");

$msgstatuslist=array("0"=>"已读","1"=>"未读");
$yesno_arr=array("0"=>"否","1"=>"是");

$optiontype_arr=array("0"=>"单选","1"=>"多选","2"=>"文本");
$formtype_arr=array("text"=>"单行文本","textarea"=>"多行文本","editor"=>"编辑器","box"=>"多选框","radio"=>"单选框","image"=>"图片","images"=>"多图片","number"=>"数字","selectbox"=>"下拉框","category"=>"栏目","money"=>"价格","datetime"=>"日期和时间","linkcat"=>"栏目关联","compose"=>"组合字段","linkspecial"=>"关联专题",'password'=>'密码字段',"province"=>"省市地区","attribute"=>"附加信息","maps"=>"地图信息");
$formtype_db=array("text"=>"varchar","textarea"=>"text","editor"=>"text","box"=>"varchar","radio"=>"int","image"=>"varchar","images"=>"text","number"=>"int","selectbox"=>"varchar","category"=>"int","money"=>"","datetime"=>"varchar","linkcat"=>"varchar","compose"=>"","linkspecial"=>"varchar","password"=>"varchar","province"=>"varchar","attribute"=>"text","maps"=>"varchar");


$menu_arr['index'][]=array('mod'=>'index','act'=>'left');

$menu_arr['index'][]=array('mod'=>'index','act'=>'close');
$menu_arr['index'][]=array('mod'=>'index','act'=>'top');
$menu_arr['index'][]=array('mod'=>'index','act'=>'index');

$menu_arr['index'][]=array('mod'=>'index','act'=>'down');
$menu_arr['index'][]=array('mod'=>'index','act'=>'center');
$menu_arr['index'][]=array('mod'=>'index','act'=>'middel');
$menu_arr['index'][]=array('mod'=>'index','act'=>'main');

//餐具，服务员价格
$dishware = 5;
$waiter = 200;
$weid =1;


session_start();
$role_arr=$ezhand->select_2_field('role','id,title','1=1');
$PowerInfo=1;
$parent_menu=$ezhand->select_3_field('menu','node,title,hide','parent_id=0');
if ($mod != 'login') {
	$ezadmin = $_SESSION['EZ_Admin'];
	if ($ezadmin['name'] == '') {
        
    	jump(u('login', 'login'));
	}
	else{
		$menu_id=$ezhand->select('menu as a,menu_access as b','a.id','a.`mod`="webset" and a.`act`="center" and a.id=b.menu_id and b.role_id="'.$ezadmin['role_id'].'"');
		if(!$menu_id){
		    $menu=$ezhand->select('menu as a,menu_access as b','a.`mod`,a.`act`','a.id=b.menu_id and b.role_id="'.$ezadmin['role_id'].'" and hide=0 and a.act<>"" and a.mod<>"" order by sort asc');
			$_GET['go_mod']=$menu['mod'];
			$_GET['go_act']=$menu['act'];
		}
		else{
			$_GET['go_mod']='webset';
			$_GET['go_act']='center';
		}
	    $url_ok = 1;
	}

	$sql = "select a.id,a.node,a.mod,a.act,a.title,a.parent_id,a.hide,a.addtion,a.topnav from " . TABLEPRE . "menu as a," . TABLEPRE . "menu_access as b where a.id=b.menu_id and b.role_id='" . $ezadmin['role_id'] . "' and a.mod<>'fun' order by a.listorder desc,a.sort desc,a.id asc";
	$query = $ezhand->query($sql);
    //echo $sql;
 


    if($query!=''){
	while ($row = $ezhand->fetch_array($query)) {
		if ($row['parent_id'] == 0) {

			$menu_arr[$row['node']] = array();
			$parent_menu[$row['node']]['title']=$row['title'];
			$parent_menu[$row['node']]['hide']=$row['hide'];
            
		} else {
			$menu_arr[$row['node']][] = $row;
            $submenu[$row['topnav']][$row['node']]=$row['node'];
		}
	}
    }
   
	$url_ok = 0;
	foreach ($menu_arr as $key => $row) {
		foreach ($row as $arr) {
		
			if (MOD==$arr['mod'] && ACT == $arr['act']) {
				$url_ok = 1;
			}
		}
	}
	
	if(MOD=='fun') $url_ok = 1;

	if ($url_ok != 1) {
		PutInfo('你没有权限');
		ez_exit();
	}
}
else{
	include (EZROOT.'/libs/checkpostandget.php');
	if(ACT!='exit' && ACT!='login'){
		ez_exit('error mod act');
	}
}

$mod_name=$mod.'/'.$act;

if(isset($_POST)){
	if(MOD!='tradelist' || ACT!='import'){
	    ez_addslashes($_POST);
	} 
}

if(file_exists(ADMINROOT.'/mod/'.$mod.'/public.act.php')){
	include(ADMINROOT.'/mod/'.$mod.'/public.act.php');
    //pp($node_arr);
}

if(file_exists(ADMINROOT.'/mod/'.$mod_name.'.act.php')){
	include(ADMINROOT.'/mod/'.$mod_name.'.act.php'); 
}
if(file_exists(ADMINROOT.'/template/'.$mod_name.'.tpl.php')){
	$_SESSION['token']=rand(100000,999999);
	$form_post_action="index.php?mod=".MOD."&act=".ACT.'&token='.$_SESSION['token']; //带有表单令牌的提交地址
    include(ADMINROOT.'/template/'.$mod_name.'.tpl.php'); //引入模板
}

$ezhand->close();
unset($ezhand);
unset($webset);



?>